home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / app.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-02  |  34.7 KB  |  1,402 lines  |  [TEXT/ALFA]

  1. /*
  2.  * Harvest C
  3.  * 
  4.  * Copyright 1991 Eric W. Sink   All rights reserved. This software is not
  5.  * freely distributable nor is it public domain.
  6.  * 
  7.  * Routines for the application version of Harvest C for the Mac.  These are
  8.  * based on TransSkel 2.6.
  9.  * 
  10.  * 
  11.  * 
  12.  */
  13.  
  14. #ifdef OLDCODE
  15. #include "conditcomp.h"
  16. #include <string.h>
  17. #include <stdio.h>
  18. #include "structs.h"
  19.  
  20. #pragma segment AppStuff
  21.  
  22. enum FileMenuItem {        /* File menu item numbers */
  23.     new = 1,            /* begin new window */
  24.     open,            /* open existing file */
  25.     close,            /* close file */
  26.     /* --- */
  27.     save = 5,            /* save file */
  28.     saveAs,            /* save under another name */
  29.     saveCopy,            /* save a copy w/o switching file binding */
  30.     revert,            /* revert to version on disk */
  31.     /* --- */
  32.     quit = 10
  33. };
  34.  
  35.  
  36. enum EditMenuItem {        /* Edit menu item numbers */
  37.     undo = 1,
  38.     /* --- */
  39.     cut = 3,
  40.     copy,
  41.     paste,
  42.     clear
  43. };
  44.  
  45. enum OptionsMenuItem {
  46.     includepath = 1,
  47.     libpath,
  48.     apppath,
  49.     codegen,
  50.     general,
  51.     saveopts = 7,
  52.     readopts,
  53.     defaultname,
  54.     warnings
  55. };
  56.  
  57. enum ProjectMenuItem {
  58.     compilefile = 1,
  59.     domake,
  60.     dolink,
  61.     smartmake,
  62.     debuggeritem,
  63. };
  64.  
  65. MenuHandle                      fileMenu;
  66. MenuHandle                      editMenu;
  67. MenuHandle                      codegenMenu;
  68. MenuHandle                      generalMenu;
  69. MenuHandle                      optionsMenu;
  70. MenuHandle                      projectMenu;
  71. MenuHandle                      warningsMenu;
  72.  
  73. void
  74. UpdateOptionsMenu(void)
  75. {
  76.     int                             ndx;
  77.     if (codegenMenu && generalMenu) {
  78. #ifndef FREECC
  79.     CheckItem(codegenMenu, 1, (Boolean) Opts.BigGlobals);
  80.     CheckItem(codegenMenu, 2, (Boolean) Opts._mc68020);
  81.     CheckItem(codegenMenu, 3, (Boolean) Opts._mc68881);
  82. #endif
  83.     CheckItem(codegenMenu, 4, (Boolean) Opts.SignedChars);
  84.     CheckItem(codegenMenu, 5, (Boolean) (!Opts.MPWoutput));
  85. #ifndef FREECC
  86.     CheckItem(codegenMenu, 6, (Boolean) Opts.Annotate);
  87. #endif
  88.     CheckItem(codegenMenu, 7, (Boolean) Opts.MBGSymbols);
  89.  
  90.     CheckItem(generalMenu, 1, (Boolean) Opts.useTrigraphs);
  91. #ifndef FREECC
  92.     CheckItem(generalMenu, 2, (Boolean) Opts.metrics);
  93.     CheckItem(generalMenu, 3, (Boolean) Opts.oopecc);
  94. #endif
  95.     CheckItem(generalMenu, 4, (Boolean) Opts.allwarnings);
  96.     CheckItem(generalMenu, 5, (Boolean) Opts.nowarnings);
  97.     CheckItem(generalMenu, 6, (Boolean) Opts.progress);
  98.     CheckItem(generalMenu, 7, (Boolean) Opts.GiveTime);
  99.     ndx = 1;
  100.     while (ndx < 34) {
  101.         CheckItem(warningsMenu, ndx, (Boolean) Opts.Warnings[ndx]);
  102.         ndx++;
  103.     }
  104.     }
  105. }
  106.  
  107. static SysEnvRec                theWorld;
  108.  
  109. void
  110. SaveOptsFile(void)
  111. {
  112.     WDPBRec                         pb;
  113.     Str255                          s;
  114.     OSErr                           bad;
  115.     short                           refnum;
  116.     long                            dirID;
  117.     int                             volrefnum;
  118.     long                            count;
  119.  
  120.     SysEnvirons(curSysEnvVers, &theWorld);
  121.  
  122.     pb.ioNamePtr = nil;
  123.     pb.ioVRefNum = theWorld.sysVRefNum;
  124.     pb.ioWDIndex = 0;
  125.     pb.ioWDProcID = 0;
  126.     PBGetWDInfo(&pb, false);
  127.  
  128.     dirID = pb.ioWDDirID;
  129.     volrefnum = pb.ioWDVRefNum;
  130.  
  131.     bad = HDelete(volrefnum, dirID, "\pHarvest C Options");
  132.     if (bad != -43)
  133.     UserFileError(bad);
  134.     bad = HCreate(volrefnum, dirID, "\pHarvest C Options", 'Jn15', '????');
  135.     UserFileError(bad);
  136.     bad = HOpen(volrefnum, dirID, "\pHarvest C Options", 2, &refnum);
  137.     UserFileError(bad);
  138.     if (!bad) {
  139.     count = sizeof(Opts);
  140.     bad = FSWrite(refnum, &count, (char *) &Opts);
  141.     DefaultOpts = Opts;
  142.     UserFileError(bad);
  143.     FSClose(refnum);
  144.     }
  145. }
  146.  
  147. int                             LostOptsFile;
  148.  
  149. int
  150. ReadOptsFile(void)
  151. {
  152.     WDPBRec                         pb;
  153.     Str255                          s;
  154.     OSErr                           bad;
  155.     short                           refnum;
  156.     long                            fcnt;
  157.     long                            dirID;
  158.     int                             volrefnum;
  159.     long                            count;
  160.  
  161.     SysEnvirons(curSysEnvVers, &theWorld);
  162.     LostOptsFile = 0;
  163.  
  164.     pb.ioNamePtr = nil;
  165.     pb.ioVRefNum = theWorld.sysVRefNum;
  166.     pb.ioWDIndex = 0;
  167.     pb.ioWDProcID = 0;
  168.     PBGetWDInfo(&pb, false);
  169.  
  170.     dirID = pb.ioWDDirID;
  171.     volrefnum = pb.ioWDVRefNum;
  172.  
  173.     bad = HOpen(volrefnum, dirID, "\pHarvest C Options", 1, &refnum);
  174.  
  175.     if (!bad) {
  176.     count = sizeof(DefaultOpts);
  177.     bad = GetEOF(refnum, &fcnt);
  178.     if (bad) {
  179.         SysBeep(1);
  180.         LostOptsFile = 1;
  181.         FSClose(refnum);
  182.         return 0;
  183.     }
  184.     if (count != fcnt) {
  185.         SysBeep(1);
  186.         FSClose(refnum);
  187.         LostOptsFile = 1;
  188.         return 0;
  189.     }
  190.     bad = FSRead(refnum, &count, (char *) &DefaultOpts);
  191.     Opts = DefaultOpts;
  192.     if (bad) {
  193.         SysBeep(1);
  194.         LostOptsFile = 1;
  195.         FSClose(refnum);
  196.         return 0;
  197.     }
  198.     bad = FSClose(refnum);
  199.     if (bad) {
  200.         SysBeep(1);
  201.         return 0;
  202.     }
  203.     UpdateOptionsMenu();
  204.     return 1;
  205.     }
  206.     SysBeep(1);
  207.     LostOptsFile = 1;
  208.     return 0;
  209. }
  210.  
  211. long                            MyCurDir;
  212. Boolean                         CurDirValid;
  213. char                            junknm[64];
  214. int                             sfinlibs;
  215.  
  216. SFReply                         dreply;
  217.  
  218. pascal short
  219. SFHookF(item, dPtr)
  220.     short                           item;
  221.     DialogPtr                       dPtr;
  222. {
  223.     /* Equates for the itmes that I've added */
  224. #define getDirButton 11
  225. #define getDirNowButton 12
  226. #define getDirMessage 13
  227.  
  228.     Str255                          messageTitle;
  229.     short                           kind;
  230.     Handle                          h;
  231.     Rect                            r;
  232.  
  233.     switch (item) {
  234.     case -1:
  235.  
  236.     /* Read in the prompt string from the resource fork, and initialize */
  237.     /* CurDirValid to FALSE. */
  238.  
  239.     GetIndString(&messageTitle, 6695, 1);
  240.     GetDItem(dPtr, getDirMessage, &kind, &h, &r);
  241.     SetIText(h, &messageTitle);
  242.     CurDirValid = false;
  243.     return item;
  244.     break;
  245.     case getDirButton:
  246.     if (dreply.fType != 0) {
  247.         MyCurDir = dreply.fType;
  248.         CurDirValid = true;
  249.         return (getCancel);
  250.     };
  251.     break;
  252.     case getDirNowButton:
  253.     MyCurDir = *(long *) CurDirStore;
  254.     CurDirValid = true;
  255.     return (getCancel);
  256.     };
  257.     return (item);        /* By default, return the item passed to us. */
  258. };
  259.  
  260.  
  261. pascal short
  262. SFHookG(item, dPtr)
  263.     short                           item;
  264.     DialogPtr                       dPtr;
  265. {
  266.     /* Equates for the itmes that I've added */
  267. #define getDirButton 11
  268. #define getDirNowButton 12
  269. #define getDirMessage 13
  270.  
  271.     Str255                          messageTitle;
  272.     short                           kind;
  273.     Handle                          h;
  274.     Rect                            r;
  275.  
  276.     switch (item) {
  277.     case -1:
  278.  
  279.     /* Read in the prompt string from the resource fork, and initialize */
  280.     /* CurDirValid to FALSE. */
  281.     GetIndString(&messageTitle, 6696, 1);
  282.     GetDItem(dPtr, getDirMessage, &kind, &h, &r);
  283.     SetIText(h, &messageTitle);
  284.     CurDirValid = false;
  285.     return item;
  286.     break;
  287.     case getDirButton:
  288.     if (dreply.fType != 0) {
  289.         MyCurDir = dreply.fType;
  290.         CurDirValid = true;
  291.         return (getCancel);
  292.     };
  293.     break;
  294.     case getDirNowButton:
  295.     MyCurDir = *(long *) CurDirStore;
  296.     CurDirValid = true;
  297.     return (getCancel);
  298.     };
  299.     return (item);        /* By default, return the item passed to us. */
  300. };
  301.  
  302.  
  303. pascal short
  304. SFHookH(item, dPtr)
  305.     short                           item;
  306.     DialogPtr                       dPtr;
  307. {
  308.     /* Equates for the itmes that I've added */
  309. #define getDirButton 11
  310. #define getDirNowButton 12
  311. #define getDirMessage 13
  312.  
  313.     Str255                          messageTitle;
  314.     short                           kind;
  315.     Handle                          h;
  316.     Rect                            r;
  317.  
  318.     switch (item) {
  319.     case -1:
  320.  
  321.     /* Read in the prompt string from the resource fork, and initialize */
  322.     /* CurDirValid to FALSE. */
  323.     GetIndString(&messageTitle, 6697, 1);
  324.     GetDItem(dPtr, getDirMessage, &kind, &h, &r);
  325.     SetIText(h, &messageTitle);
  326.     CurDirValid = false;
  327.     return item;
  328.     break;
  329.     case getDirButton:
  330.     if (dreply.fType != 0) {
  331.         MyCurDir = dreply.fType;
  332.         CurDirValid = true;
  333.         return (getCancel);
  334.     };
  335.     break;
  336.     case getDirNowButton:
  337.     MyCurDir = *(long *) CurDirStore;
  338.     CurDirValid = true;
  339.     return (getCancel);
  340.     };
  341.     return (item);        /* By default, return the item passed to us. */
  342. };
  343.  
  344.  
  345. pascal                          Boolean
  346. FoldersOnly(p)
  347.     ParmBlkPtr                      p;
  348. {
  349.     /* Normally, folders are ALWAYS shown, and aren't even passed to         */
  350.     /* this file filter for judgement. Under such circumstances, it is         */
  351.     /* only necessary to blindly return TRUE (allow no files whatsoever).     */
  352.     /* However, Standard File is not documented in such a manner, and         */
  353.     /* this feature may not be TRUE in the future. Therefore, we DO check     */
  354.     /* to see if the entry passed to us describes a file or a directory.     */
  355.  
  356.     if ((p->fileParam.ioFlAttrib & 0x10) != 0)
  357.     return (false);
  358.     return (true);
  359. };
  360.  
  361.  
  362.  
  363. InFileVia_t
  364. FileSelectorF(void)
  365. {
  366.     /*
  367.      * The objective here is to call SFGetFile, munge the result into a
  368.      * InFileVia structure and return it.  This involves translation of the
  369.      * wdrefnum to a volrefnum, dirID pair, etc...
  370.      */
  371.     InFileVia_t                     result;
  372.     SFTypeList                      typeList;
  373.     Point                           where =
  374.     {64, 64};
  375.     Str255                          s;
  376.  
  377.     *(long *) CurDirStore = Opts.StdIncludeDir;
  378.     *(short *) SFSaveDisk = -(Opts.StdIncludeVol);
  379.  
  380.     SFPGetFile(where,        /* location */
  381.            "\pSpace for Rent",    /* vestigial string */
  382.            FoldersOnly,    /* fileFilter */
  383.            -1,        /* numtypes; -1 means all */
  384.            &typeList,    /* array to types to show */
  385.            SFHookF,        /* dlgHook */
  386.            &dreply,        /* record for returned values */
  387.            6694,
  388.            NULL);
  389.     if (CurDirValid) {
  390.     result = Ealloc(sizeof(InFile_t));
  391.     Via(result)->dirID = MyCurDir;
  392.     Via(result)->volrefnum = -(*(short *) SFSaveDisk);
  393.     p2cstr(dreply.fName);
  394.     strcpy(Via(result)->fname, dreply.fName);
  395.     Via(result)->next = NULL;
  396.     return result;
  397.     } else
  398.     return NULL;
  399. }
  400.  
  401. InFileVia_t
  402. FileSelectorG(void)
  403. {
  404.     /*
  405.      * The objective here is to call SFGetFile, munge the result into a
  406.      * InFileVia structure and return it.  This involves translation of the
  407.      * wdrefnum to a volrefnum, dirID pair, etc...
  408.      */
  409.     InFileVia_t                     result;
  410.     SFTypeList                      typeList;
  411.     Point                           where =
  412.     {64, 64};
  413.     Str255                          s;
  414.  
  415.     *(long *) CurDirStore = Opts.StdLibDir;
  416.     *(short *) SFSaveDisk = -(Opts.StdLibVol);
  417.  
  418.     SFPGetFile(where,        /* location */
  419.            "\pSpace for Rent",    /* vestigial string */
  420.            FoldersOnly,    /* fileFilter */
  421.            -1,        /* numtypes; -1 means all */
  422.            &typeList,    /* array to types to show */
  423.            SFHookG,        /* dlgHook */
  424.            &dreply,        /* record for returned values */
  425.            6694,
  426.            NULL);
  427.     if (CurDirValid) {
  428.     result = Ealloc(sizeof(InFile_t));
  429.     Via(result)->dirID = MyCurDir;
  430.     Via(result)->volrefnum = -(*(short *) SFSaveDisk);
  431.     p2cstr(dreply.fName);
  432.     strcpy(Via(result)->fname, dreply.fName);
  433.     Via(result)->next = NULL;
  434.     return result;
  435.     } else
  436.     return NULL;
  437. }
  438.  
  439. InFileVia_t
  440. FileSelectorH(void)
  441. {
  442.     /*
  443.      * The objective here is to call SFGetFile, munge the result into a
  444.      * InFileVia structure and return it.  This involves translation of the
  445.      * wdrefnum to a volrefnum, dirID pair, etc...
  446.      */
  447.     InFileVia_t                     result;
  448.     SFTypeList                      typeList;
  449.     Point                           where =
  450.     {64, 64};
  451.     Str255                          s;
  452.  
  453.     *(long *) CurDirStore = Opts.StdAppDir;
  454.     *(short *) SFSaveDisk = -(Opts.StdAppVol);
  455.  
  456.     SFPGetFile(where,        /* location */
  457.            "\pSpace for Rent",    /* vestigial string */
  458.            FoldersOnly,    /* fileFilter */
  459.            -1,        /* numtypes; -1 means all */
  460.            &typeList,    /* array to types to show */
  461.            SFHookH,        /* dlgHook */
  462.            &dreply,        /* record for returned values */
  463.            6694,
  464.            NULL);
  465.     if (CurDirValid) {
  466.     result = Ealloc(sizeof(InFile_t));
  467.     Via(result)->dirID = MyCurDir;
  468.     Via(result)->volrefnum = -(*(short *) SFSaveDisk);
  469.     p2cstr(dreply.fName);
  470.     strcpy(Via(result)->fname, dreply.fName);
  471.     Via(result)->next = NULL;
  472.     return result;
  473.     } else
  474.     return NULL;
  475. }
  476.  
  477. InFileVia_t
  478. FileSelector(OSType filetype)
  479. {
  480.     /*
  481.      * The objective here is to call SFGetFile, munge the result into a
  482.      * InFileVia structure and return it.  This involves translation of the
  483.      * wdrefnum to a volrefnum, dirID pair, etc...
  484.      */
  485.     InFileVia_t                     result;
  486.     SFTypeList                      typeList;
  487.     SFReply                         reply;
  488.     Point                           where =
  489.     {64, 64};
  490.     typeList[0] = filetype;
  491.     SFGetFile(where, "\pnothing", NULL, 1, &typeList, NULL, &reply);
  492.     if (reply.good) {
  493.     WDPBRec                         blk;
  494.     long                            dirID;
  495.     short                           volrefnum;
  496.     blk.ioNamePtr = NULL;
  497.     blk.ioVRefNum = reply.vRefNum;
  498.     blk.ioWDIndex = 0;
  499.     blk.ioWDProcID = 0;
  500.     PBGetWDInfo(&blk, 0);
  501.     dirID = blk.ioWDDirID;
  502.     volrefnum = blk.ioWDVRefNum;
  503.     result = Ealloc(sizeof(InFile_t));
  504.     Via(result)->dirID = dirID;
  505.     Via(result)->volrefnum = volrefnum;
  506.     p2cstr(reply.fName);
  507.     strcpy(Via(result)->fname, reply.fName);
  508.     Via(result)->next = NULL;
  509.     return result;
  510.     } else
  511.     return NULL;
  512. }
  513.  
  514. pascal short
  515. SFHookE(item, theDialog)
  516.     short                           item;
  517.     DialogPtr                       theDialog;
  518. {
  519.     Handle                          itemToChange;
  520.     Rect                            itemBox;
  521.     short                           itemType;
  522.  
  523.     switch (item) {
  524.     default:
  525.     return item;
  526.     break;
  527.     }
  528.     return item;
  529. }
  530.  
  531. InFileVia_t
  532. FileSelectorE()
  533. {
  534.     /*
  535.      * The objective here is to call SFPPutFile, munge the result into a
  536.      * InFileVia structure and return it.  This involves translation of the
  537.      * wdrefnum to a volrefnum, dirID pair, etc...
  538.      */
  539.     InFileVia_t                     result;
  540.     SFReply                         reply;
  541.     Point                           where =
  542.     {64, 64};
  543.     char                            pname[256];
  544.     strcpy(pname, Opts.StdAppName);
  545.     c2pstr(pname);
  546.     *(long *) CurDirStore = Opts.StdAppDir;
  547.     *(short *) SFSaveDisk = -(Opts.StdAppVol);
  548.  
  549.     SFPPutFile(where, "\pEnter name of app", pname, SFHookE, &reply, 6693, NULL);
  550.     if (reply.good) {
  551.     WDPBRec                         blk;
  552.     long                            dirID;
  553.     short                           volrefnum;
  554.     blk.ioNamePtr = NULL;
  555.     blk.ioVRefNum = reply.vRefNum;
  556.     blk.ioWDIndex = 0;
  557.     blk.ioWDProcID = 0;
  558.     PBGetWDInfo(&blk, 0);
  559.     dirID = blk.ioWDDirID;
  560.     volrefnum = blk.ioWDVRefNum;
  561.     result = Ealloc(sizeof(InFile_t));
  562.     Via(result)->dirID = dirID;
  563.     Via(result)->volrefnum = volrefnum;
  564.     p2cstr(reply.fName);
  565.     strcpy(Via(result)->fname, reply.fName);
  566.     Via(result)->next = NULL;
  567.     return result;
  568.     } else
  569.     return NULL;
  570. }
  571.  
  572. int
  573. FileSelectorK()
  574. {
  575.     InFileVia_t                     result;
  576.     SFReply                         reply;
  577.     Point                           where =
  578.     {64, 64};
  579.     char                            pname[256];
  580.     strcpy(pname, Opts.StdAppName);
  581.     c2pstr(pname);
  582.     SFPPutFile(where, "\pDefault app name", pname, SFHookE, &reply, 6700, NULL);
  583.     if (reply.good) {
  584.     p2cstr(reply.fName);
  585.     strcpy(Opts.StdAppName, reply.fName);
  586.     return 1;
  587.     } else
  588.     return 0;
  589. }
  590.  
  591. pascal short
  592. SFHookB(item, theDialog)
  593.     short                           item;
  594.     DialogPtr                       theDialog;
  595. {
  596.     Handle                          itemToChange;
  597.     Rect                            itemBox;
  598.     short                           itemType;
  599.     char                            buttonTitle[256];
  600.  
  601.     switch (item) {
  602.     case -1:
  603.     GetIndString((char *) buttonTitle, 6688, 1);
  604.     if (buttonTitle[0] != 0) {
  605.         GetDItem(theDialog, 1, &itemType, &itemToChange, &itemBox);
  606.         SetCTitle((ControlHandle) itemToChange, buttonTitle);
  607.     }
  608.     return item;
  609.     break;
  610.     break;
  611.     default:
  612.     return item;
  613.     break;
  614.     }
  615.     return item;
  616. }
  617.  
  618. InFileVia_t
  619. FileSelectorB(OSType filetype)
  620. {
  621.     /*
  622.      * The objective here is to call SFPGetFile, munge the result into a
  623.      * InFileVia structure and return it.  This involves translation of the
  624.      * wdrefnum to a volrefnum, dirID pair, etc...
  625.      */
  626.     InFileVia_t                     result;
  627.     SFTypeList                      typeList;
  628.     SFReply                         reply;
  629.     Point                           where =
  630.     {64, 64};
  631.     typeList[0] = filetype;
  632.     *(long *) CurDirStore = Opts.StdAppDir;
  633.     *(short *) SFSaveDisk = -(Opts.StdAppVol);
  634.  
  635.     SFPGetFile(where, "\pnothing", NULL, 1, &typeList, SFHookB, &reply, 6687, NULL);
  636.     if (reply.good) {
  637.     WDPBRec                         blk;
  638.     long                            dirID;
  639.     short                           volrefnum;
  640.     blk.ioNamePtr = NULL;
  641.     blk.ioVRefNum = reply.vRefNum;
  642.     blk.ioWDIndex = 0;
  643.     blk.ioWDProcID = 0;
  644.     PBGetWDInfo(&blk, 0);
  645.     dirID = blk.ioWDDirID;
  646.     volrefnum = blk.ioWDVRefNum;
  647.     result = Ealloc(sizeof(InFile_t));
  648.     Via(result)->dirID = dirID;
  649.     Via(result)->volrefnum = volrefnum;
  650.     p2cstr(reply.fName);
  651.     strcpy(Via(result)->fname, reply.fName);
  652.     Via(result)->next = NULL;
  653.     return result;
  654.     } else
  655.     return NULL;
  656. }
  657.  
  658. pascal short
  659. SFHookC(item, theDialog)
  660.     short                           item;
  661.     DialogPtr                       theDialog;
  662. {
  663.     Handle                          itemToChange;
  664.     Rect                            itemBox;
  665.     short                           itemType;
  666.     char                            buttonTitle[256];
  667.  
  668.     switch (item) {
  669.     case -1:
  670.     GetIndString((char *) buttonTitle, 6689, 1);
  671.     if (buttonTitle[0] != 0) {
  672.         GetDItem(theDialog, 1, &itemType, &itemToChange, &itemBox);
  673.         SetCTitle((ControlHandle) itemToChange, buttonTitle);
  674.     }
  675.     return item;
  676.     break;
  677.     break;
  678.     default:
  679.     return item;
  680.     break;
  681.     }
  682.     return item;
  683. }
  684.  
  685. InFileVia_t
  686. FileSelectorC(OSType filetype)
  687. {
  688.     /*
  689.      * The objective here is to call SFPGetFile, munge the result into a
  690.      * InFileVia structure and return it.  This involves translation of the
  691.      * wdrefnum to a volrefnum, dirID pair, etc...
  692.      */
  693.     InFileVia_t                     result;
  694.     SFTypeList                      typeList;
  695.     SFReply                         reply;
  696.     Point                           where =
  697.     {64, 64};
  698.     typeList[0] = filetype;
  699.     *(long *) CurDirStore = Opts.StdAppDir;
  700.     *(short *) SFSaveDisk = -(Opts.StdAppVol);
  701.  
  702.     SFPGetFile(where, "\pnothing", NULL, 1, &typeList, SFHookC, &reply, 6687, NULL);
  703.     if (reply.good) {
  704.     WDPBRec                         blk;
  705.     long                            dirID;
  706.     short                           volrefnum;
  707.     blk.ioNamePtr = NULL;
  708.     blk.ioVRefNum = reply.vRefNum;
  709.     blk.ioWDIndex = 0;
  710.     blk.ioWDProcID = 0;
  711.     PBGetWDInfo(&blk, 0);
  712.     dirID = blk.ioWDDirID;
  713.     volrefnum = blk.ioWDVRefNum;
  714.     result = Ealloc(sizeof(InFile_t));
  715.     Via(result)->dirID = dirID;
  716.     Via(result)->volrefnum = volrefnum;
  717.     p2cstr(reply.fName);
  718.     strcpy(Via(result)->fname, reply.fName);
  719.     Via(result)->next = NULL;
  720.     return result;
  721.     } else
  722.     return NULL;
  723. }
  724.  
  725. pascal short
  726. SFHookD(item, theDialog)
  727.     short                           item;
  728.     DialogPtr                       theDialog;
  729. {
  730.     Handle                          itemToChange;
  731.     Rect                            itemBox;
  732.     short                           itemType;
  733.     char                            buttonTitle[256];
  734.  
  735.     switch (item) {
  736.     case -1:
  737.     GetIndString((char *) buttonTitle, 6690, 1);
  738.     if (buttonTitle[0] != 0) {
  739.         GetDItem(theDialog, 1, &itemType, &itemToChange, &itemBox);
  740.         SetCTitle((ControlHandle) itemToChange, buttonTitle);
  741.     }
  742.     if (sfinlibs) {
  743.         sfinlibs = 1;
  744.  
  745.         *(long *) CurDirStore = Opts.StdLibDir;
  746.         *(short *) SFSaveDisk = -(Opts.StdLibVol);
  747.  
  748.         GetDItem(theDialog, 11, &itemType, &itemToChange, &itemBox);
  749.         SetCtlValue((ControlHandle) itemToChange, 1);
  750.         GetDItem(theDialog, 12, &itemType, &itemToChange, &itemBox);
  751.         SetCtlValue((ControlHandle) itemToChange, 0);
  752.     } else {
  753.         sfinlibs = 0;
  754.         *(long *) CurDirStore = Opts.StdAppDir;
  755.         *(short *) SFSaveDisk = -(Opts.StdAppVol);
  756.  
  757.         GetDItem(theDialog, 11, &itemType, &itemToChange, &itemBox);
  758.         SetCtlValue((ControlHandle) itemToChange, 0);
  759.         GetDItem(theDialog, 12, &itemType, &itemToChange, &itemBox);
  760.         SetCtlValue((ControlHandle) itemToChange, 1);
  761.     }
  762.     return 101;
  763.     break;
  764.     case 11:
  765.     if (!sfinlibs) {
  766.         sfinlibs = 1;
  767.  
  768.         *(long *) CurDirStore = Opts.StdLibDir;
  769.         *(short *) SFSaveDisk = -(Opts.StdLibVol);
  770.  
  771.         GetDItem(theDialog, 11, &itemType, &itemToChange, &itemBox);
  772.         SetCtlValue((ControlHandle) itemToChange, 1);
  773.         GetDItem(theDialog, 12, &itemType, &itemToChange, &itemBox);
  774.         SetCtlValue((ControlHandle) itemToChange, 0);
  775.         return 101;
  776.     }
  777.     return item;
  778.     break;
  779.     case 12:
  780.     if (sfinlibs) {
  781.         sfinlibs = 0;
  782.         *(long *) CurDirStore = Opts.StdAppDir;
  783.         *(short *) SFSaveDisk = -(Opts.StdAppVol);
  784.  
  785.         GetDItem(theDialog, 11, &itemType, &itemToChange, &itemBox);
  786.         SetCtlValue((ControlHandle) itemToChange, 0);
  787.         GetDItem(theDialog, 12, &itemType, &itemToChange, &itemBox);
  788.         SetCtlValue((ControlHandle) itemToChange, 1);
  789.         return 101;
  790.     }
  791.     return item;
  792.     break;
  793.     case 13:
  794.     return getCancel;
  795.     break;
  796.     break;
  797.     default:
  798.     return item;
  799.     break;
  800.     }
  801.     return item;
  802. }
  803.  
  804. InFileVia_t
  805. FileSelectorD(OSType filetype)
  806. {
  807.     /*
  808.      * The objective here is to call SFPGetFile, munge the result into a
  809.      * InFileVia structure and return it.  This involves translation of the
  810.      * wdrefnum to a volrefnum, dirID pair, etc...
  811.      */
  812.     InFileVia_t                     result;
  813.     SFTypeList                      typeList;
  814.     SFReply                         reply;
  815.     Point                           where =
  816.     {64, 64};
  817.     typeList[0] = filetype;
  818.  
  819.     SFPGetFile(where, "\pnothing", NULL, 1, &typeList, SFHookD, &reply, 6691, NULL);
  820.     if (reply.good) {
  821.     WDPBRec                         blk;
  822.     long                            dirID;
  823.     short                           volrefnum;
  824.     blk.ioNamePtr = NULL;
  825.     blk.ioVRefNum = reply.vRefNum;
  826.     blk.ioWDIndex = 0;
  827.     blk.ioWDProcID = 0;
  828.     PBGetWDInfo(&blk, 0);
  829.     dirID = blk.ioWDDirID;
  830.     volrefnum = blk.ioWDVRefNum;
  831.     result = Ealloc(sizeof(InFile_t));
  832.     Via(result)->dirID = dirID;
  833.     Via(result)->volrefnum = volrefnum;
  834.     p2cstr(reply.fName);
  835.     strcpy(Via(result)->fname, reply.fName);
  836.     Via(result)->next = NULL;
  837.     return result;
  838.     } else
  839.     return NULL;
  840. }
  841.  
  842. void
  843. UpdateFileMenu(void)
  844. {
  845.     WindowPtr                       theWind;
  846.     DisableItem(fileMenu, close);
  847.     DisableItem(fileMenu, save);
  848.     DisableItem(fileMenu, saveAs);
  849.     DisableItem(fileMenu, saveCopy);
  850.     DisableItem(fileMenu, revert);
  851.     if ((theWind = FrontWindow()) != 0) {
  852.     EnableItem(fileMenu, close);
  853.     }
  854.     if (IsTWindow(theWind)) {
  855.     EnableItem(fileMenu, saveAs);
  856.     EnableItem(fileMenu, saveCopy);
  857.     if (!GetTWindowFile(theWind, NULL)) {
  858.         EnableItem(fileMenu, save);
  859.     } else if (IsTWindowDirty(theWind)) {
  860.         EnableItem(fileMenu, save);
  861.         EnableItem(fileMenu, revert);
  862.     }
  863.     }
  864. }
  865.  
  866. WindowPtr                       lastFront;
  867.  
  868. void
  869. CheckFront(void)
  870. {
  871.     if (lastFront != FrontWindow()) {
  872.     UpdateFileMenu();
  873.     lastFront = FrontWindow();
  874.     }
  875. }
  876.  
  877. WindowPtr
  878. BuildWindow(int bindtofile, char *name)
  879. {
  880.     Rect                            r;
  881.     static int                      count = 0;
  882.     int                             offset;
  883.     if (!FrontWindow())
  884.     count = 0;
  885.     SetRect(&r, 0, 0, 400, 275);
  886.     offset = 50 + 25 * (count++ % 4);
  887.     OffsetRect(&r, offset, offset);
  888.     return NewTWindow(&r, name, 1, ((void *) -1), 1, 0L, bindtofile);
  889. }
  890.  
  891. /*
  892.  * File menu handler
  893.  */
  894.  
  895. void
  896. DoFileMenu(item)
  897.     short                           item;
  898. {
  899.     WindowPtr                       theWind;
  900.     theWind = FrontWindow();
  901.     switch (item) {
  902.     case new:
  903.     BuildWindow(0, NULL);
  904.     break;
  905.  
  906.     case open:
  907.     BuildWindow(1, NULL);
  908.     break;
  909.  
  910.     case close:
  911.     if (IsTWindow(theWind))
  912.         TWindowClose(theWind);
  913.     else
  914.         CloseDeskAcc(((WindowPeek) theWind)->windowKind);
  915.     break;
  916.  
  917.     case save:
  918.     TWindowSave(theWind);
  919.     break;
  920.  
  921.     case saveAs:
  922.     TWindowSaveAs(theWind);
  923.     break;
  924.  
  925.     case saveCopy:
  926.     TWindowSaveCopy(theWind);
  927.     break;
  928.  
  929.     case revert:
  930.     TWindowRevert(theWind);
  931.     break;
  932.  
  933.     case quit:
  934.     if (ClobberTWindows())
  935.         SkelWhoa();
  936.     break;
  937.  
  938.     }
  939.     UpdateFileMenu();
  940. }
  941.  
  942.  
  943. /*
  944.  * Handle Options menu items
  945.  */
  946.  
  947. void
  948. DoOptionsMenu(item)
  949.     short                           item;
  950. {
  951.     InFileVia_t                     whatfile;
  952.     switch (item) {
  953.     case includepath:
  954.     whatfile = FileSelectorF();
  955.     if (whatfile) {
  956.         /*
  957.          * We now set the default include path to the path to the chosen
  958.          * file
  959.          */
  960.         Opts.StdIncludeVol = Via(whatfile)->volrefnum;
  961.         Opts.StdIncludeDir = Via(whatfile)->dirID;
  962.         Efree(whatfile);
  963.     }
  964.     break;
  965.     case libpath:
  966.     whatfile = FileSelectorG();
  967.     if (whatfile) {
  968.         /*
  969.          * We now set the default include path to the path to the chosen
  970.          * file
  971.          */
  972.         Opts.StdLibVol = Via(whatfile)->volrefnum;
  973.         Opts.StdLibDir = Via(whatfile)->dirID;
  974.         Efree(whatfile);
  975.     }
  976.     break;
  977.     case apppath:
  978.     whatfile = FileSelectorH();
  979.     if (whatfile) {
  980.         /*
  981.          * We now set the default include path to the path to the chosen
  982.          * file
  983.          */
  984.         Opts.StdAppVol = Via(whatfile)->volrefnum;
  985.         Opts.StdAppDir = Via(whatfile)->dirID;
  986.         Efree(whatfile);
  987.     }
  988.     break;
  989.     case saveopts:
  990.     SaveOptsFile();
  991.     break;
  992.     case readopts:
  993.     ReadOptsFile();
  994.     break;
  995.     case defaultname:
  996.     FileSelectorK();
  997.     default:
  998.     break;
  999.     }
  1000. }
  1001.  
  1002.  
  1003. /*
  1004.  * Handle code gen menu items
  1005.  */
  1006.  
  1007. void
  1008. DoCodeGenMenu(item)
  1009.     short                           item;
  1010. {
  1011.     switch (item) {
  1012. #ifndef FREECC
  1013.     case 1:
  1014.     Opts.BigGlobals = !Opts.BigGlobals;
  1015.     break;
  1016.     case 2:
  1017.     Opts._mc68020 = !Opts._mc68020;
  1018.     break;
  1019.     case 3:
  1020.     Opts._mc68881 = !Opts._mc68881;
  1021.     break;
  1022. #endif
  1023.     case 4:
  1024.     Opts.SignedChars = !Opts.SignedChars;
  1025.     break;
  1026.     case 5:
  1027.     Opts.MPWoutput = !Opts.MPWoutput;
  1028.     break;
  1029. #ifndef FREECC
  1030.     case 6:
  1031.     Opts.Annotate = !Opts.Annotate;
  1032.     break;
  1033. #endif
  1034.     case 7:
  1035.     Opts.MBGSymbols = !Opts.MBGSymbols;
  1036.     break;
  1037.     default:
  1038.     break;
  1039.     }
  1040.     UpdateOptionsMenu();
  1041. }
  1042.  
  1043. void
  1044. DoWarningsMenu(item)
  1045.     short                           item;
  1046. {
  1047.     Opts.Warnings[item] = !Opts.Warnings[item];
  1048.     UpdateOptionsMenu();
  1049. }
  1050.  
  1051. /*
  1052.  * Handle general menu items
  1053.  */
  1054.  
  1055. void
  1056. DoGeneralMenu(item)
  1057.     short                           item;
  1058. {
  1059.     switch (item) {
  1060.     case 1:
  1061.     Opts.useTrigraphs = !Opts.useTrigraphs;
  1062.     break;
  1063. #ifndef FREECC
  1064.     case 2:
  1065.     Opts.metrics = !Opts.metrics;
  1066.     break;
  1067.     case 3:
  1068.     Opts.oopecc = !Opts.oopecc;
  1069.     break;
  1070. #endif
  1071.     case 4:
  1072.     Opts.allwarnings = !Opts.allwarnings;
  1073.     if (Opts.allwarnings)
  1074.         Opts.nowarnings = 0;
  1075.     break;
  1076.     case 5:
  1077.     Opts.nowarnings = !Opts.nowarnings;
  1078.     if (Opts.nowarnings)
  1079.         Opts.allwarnings = 0;
  1080.     break;
  1081.     case 6:
  1082.     Opts.progress = !Opts.progress;
  1083.     break;
  1084.     case 7:
  1085.     Opts.GiveTime = !Opts.GiveTime;
  1086.     break;
  1087.     default:
  1088.     break;
  1089.     }
  1090.     UpdateOptionsMenu();
  1091. }
  1092.  
  1093. void
  1094. DoCompileFile(void)
  1095. {
  1096.     InFileVia_t                     whatfile;
  1097.     /* Put up a file dialog, and compile the given file */
  1098.     whatfile = FileSelectorB('TEXT');
  1099.     if (whatfile) {
  1100.     MoveHHi((Handle) whatfile);
  1101.     HLock((Handle) whatfile);
  1102.     SingleFile(Via(whatfile)->fname,
  1103.            Via(whatfile)->volrefnum, Via(whatfile)->dirID);
  1104.     HUnlock((Handle) whatfile);
  1105.     Efree(whatfile);
  1106.     }
  1107. }
  1108.  
  1109. /*
  1110.  * Handle Project menu items
  1111.  */
  1112.  
  1113. void
  1114. DoProjectMenu(item)
  1115.     short                           item;
  1116. {
  1117.     InFileVia_t                     whatfile;
  1118.     InFileVia_t                     firstfile;
  1119.     InFileVia_t                     destfile;
  1120.     InFileVia_t                     nextfile;
  1121.     switch (item) {
  1122.     case compilefile:
  1123.     DoCompileFile();
  1124.     break;
  1125.     case domake:
  1126.     /* Put up a file dialog, and 'make' with the given file */
  1127.     whatfile = FileSelectorC('TEXT');
  1128.     if (whatfile) {
  1129.         Opts.StdBuildDir = Via(whatfile)->dirID;
  1130.         Opts.StdBuildVol = Via(whatfile)->volrefnum;
  1131.         MoveHHi((Handle) whatfile);
  1132.         HLock((Handle) whatfile);
  1133.         EMake(Via(whatfile)->fname,
  1134.           Via(whatfile)->volrefnum, Via(whatfile)->dirID, 1);
  1135.         HUnlock((Handle) whatfile);
  1136.         Efree(whatfile);
  1137.     }
  1138.     break;
  1139.     case dolink:
  1140.  
  1141.     sfinlibs = 0;
  1142.     nextfile = firstfile = FileSelectorD('OBJ ');
  1143.     if (nextfile) {
  1144.         whatfile = nextfile;
  1145.         while (nextfile) {
  1146.         nextfile = FileSelectorD('OBJ ');
  1147.         if (nextfile) {
  1148.             Via(nextfile)->next = whatfile;
  1149.             whatfile = nextfile;
  1150.         }
  1151.         }
  1152.         destfile = FileSelectorE();
  1153.         if (destfile) {
  1154.         HLock((Handle) destfile);
  1155.         /* Call a link routine with this set of files */
  1156.         ELink(whatfile, Via(destfile)->fname, Via(destfile)->volrefnum, Via(destfile)->dirID);
  1157.         HUnlock((Handle) destfile);
  1158.         }
  1159.     }
  1160.     break;
  1161.     case smartmake:
  1162.     /* Put up a file dialog, and 'make' with the given file */
  1163.     whatfile = FileSelectorC('TEXT');
  1164.     if (whatfile) {
  1165.         Opts.StdBuildDir = Via(whatfile)->dirID;
  1166.         Opts.StdBuildVol = Via(whatfile)->volrefnum;
  1167.         MoveHHi((Handle) whatfile);
  1168.         HLock((Handle) whatfile);
  1169.         EMake(Via(whatfile)->fname,
  1170.           Via(whatfile)->volrefnum, Via(whatfile)->dirID, 0);
  1171.         HUnlock((Handle) whatfile);
  1172.         Efree(whatfile);
  1173.     }
  1174.     break;
  1175.     case debuggeritem:
  1176.     Debugger();
  1177.     break;
  1178.     default:
  1179.     break;
  1180.     }
  1181. }
  1182.  
  1183.  
  1184. void
  1185. WindowActivate(Boolean x)
  1186. {
  1187. }
  1188.  
  1189.  
  1190. void
  1191. CloseIt(void)
  1192. {
  1193.     WindowPtr                       theWind;
  1194.     GetPort(&theWind);
  1195.     TWindowClose(theWind);
  1196.     UpdateFileMenu();
  1197. }
  1198.  
  1199. void
  1200. SetUpWarningsMenu(void)
  1201. {
  1202.     warningsMenu = NewMenu(224, "\pWarnings");
  1203.  
  1204.     AppendMenu(warningsMenu, "\pEmpty expression stmt;Multi-character constant;Redundant cast;\
  1205. Equivalence test of floating type");
  1206.  
  1207.     AppendMenu(warningsMenu, "\pDiscarded function result;Assignment as if conditional;\
  1208. Non-void function has no return statement;Constant expression as if condition");
  1209.  
  1210.     AppendMenu(warningsMenu, "\pComparison of pointer and integer;Assignment of nonequivalent type to a pointer;\
  1211. Return of nonequivalent type to a pointer");
  1212.  
  1213.     AppendMenu(warningsMenu, "\pPass of nonequivalent type to a pointer;\
  1214. Constant expression as switch condition");
  1215.  
  1216.     AppendMenu(warningsMenu, "\pConstant expression as while loop condition;\
  1217. Constant expression as do-while loop condition");
  1218.  
  1219.     AppendMenu(warningsMenu, "\pConstant expression as for loop condition;\
  1220. Switch expression not of integral type;\
  1221. Volatile is not handled by this compiler;\
  1222. (-");
  1223.  
  1224.     AppendMenu(warningsMenu, "\pUnused variable ;\
  1225. Dead code;\
  1226. Implicit decl;\
  1227. Re#definition;\
  1228. Possible nested comment");
  1229.  
  1230.     AppendMenu(warningsMenu, "\p(-;\
  1231. goto statement found;\
  1232. Multiple function returns;\
  1233. Empty compound statement");
  1234.  
  1235.     AppendMenu(warningsMenu, "\pMissing function return type - default to int;\
  1236. Trigraph found;\
  1237. (-;\
  1238. pascal keyword found;\
  1239. (-;\
  1240. Semicolon after function body");
  1241.  
  1242.     SkelMenu(warningsMenu, DoWarningsMenu, NULL, true, false);
  1243. }
  1244.  
  1245. #pragma segment AppInit
  1246.  
  1247. void
  1248. ApplicationInit(void)
  1249. {
  1250.     SkelInit(NULL, 450);
  1251.  
  1252.     InitDefaultOpts();
  1253.     InitOpts();
  1254.  
  1255.     SkelApple("\pAbout Harvest C...", DoAbout);
  1256.  
  1257. #ifdef Undefined
  1258.     fileMenu = NewMenu(1000, "\pFile");
  1259.     AppendMenu(fileMenu, "\pNew/N;Open.../O;Close/W;(-;Save/S;Save As...");
  1260.     AppendMenu(fileMenu, "\pSave a Copy As...;Revert/R;(-;Quit/Q");
  1261. #endif
  1262.     fileMenu = GetMenu(1000);
  1263.     SkelMenu(fileMenu, DoFileMenu, NULL, false, false);
  1264.  
  1265. #ifdef Undefined
  1266.     editMenu = NewMenu(1001, "\pEdit");
  1267.     AppendMenu(editMenu, "\p(Undo/Z;(-;Cut/X;Copy/C;Paste/V;Clear");
  1268. #endif
  1269.     editMenu = GetMenu(1001);
  1270.     SkelMenu(editMenu, TWindowEditOp, NULL, false, false);
  1271.  
  1272.     codegenMenu = NewMenu(222, "\pBig globals");
  1273. #ifdef FREECC
  1274.     AppendMenu(codegenMenu, "\p(Big globals;(mc68020;(mc68881;signed char;68k source;(Annotate;MacsBug symbols");
  1275. #else
  1276.     AppendMenu(codegenMenu, "\pBig globals;mc68020;mc68881;signed char;68k source;Annotate;MacsBug symbols");
  1277. #endif
  1278.     SkelMenu(codegenMenu, DoCodeGenMenu, NULL, true, false);
  1279.  
  1280.     generalMenu = NewMenu(223, "\pTrigraphs");
  1281. #ifdef FREECC
  1282.     AppendMenu(generalMenu, "\pTrigraphs;(Metrics;(OOP;All warnings;No warnings;Progress");
  1283. #else
  1284.     AppendMenu(generalMenu, "\pTrigraphs;Metrics;OOP;All warnings;No warnings;Progress");
  1285. #endif
  1286.     SkelMenu(generalMenu, DoGeneralMenu, NULL, true, false);
  1287.  
  1288.     SetUpWarningsMenu();
  1289.  
  1290.     UpdateOptionsMenu();
  1291.  
  1292.     optionsMenu = NewMenu(1002, "\pOptions");
  1293.     AppendMenu(optionsMenu, "\pInclude Path...;Lib Path...;App Path...;Code generation;General;(-;Save defaults;Read Defaults;Default app name...;Warnings");
  1294.     SkelMenu(optionsMenu, DoOptionsMenu, NULL, false, false);
  1295.     SetItemCmd(optionsMenu, codegen, 0x1B);
  1296.     SetItemMark(optionsMenu, codegen, (char) 222);
  1297.     SetItemCmd(optionsMenu, general, 0x1B);
  1298.     SetItemMark(optionsMenu, general, (char) 223);
  1299.     SetItemCmd(optionsMenu, warnings, 0x1B);
  1300.     SetItemMark(optionsMenu, warnings, (char) 224);
  1301.  
  1302. #ifdef Undefined
  1303.     projectMenu = NewMenu(1003, "\pProject");
  1304.     AppendMenu(projectMenu, "\pCompile File.../K;Build.../M;Link...;Make...;Debug/G;");
  1305. #endif
  1306.     projectMenu = GetMenu(1003);
  1307.     SkelMenu(projectMenu, DoProjectMenu, NULL, false, true);
  1308.  
  1309.     UpdateFileMenu();
  1310.  
  1311.     SetTWindowCreator('ALFA');
  1312.     SetTWindowStyle(NULL, 3, 9, 0, teJustLeft);
  1313.     SetTWindowProcs(NULL, UpdateFileMenu, WindowActivate, CloseIt);
  1314.  
  1315.     if (LostOptsFile) {
  1316.     LostOptsFile = 0;
  1317.     FakeAlert("\pCouldn't read ", "\pConfig file in ", "\pSystem Folder.", "\p",
  1318.           1, 1, "\pOk", "\p", "\p");
  1319.     }
  1320. }
  1321.  
  1322. #pragma segment AppStuff
  1323.  
  1324. int
  1325. GiveTime(void)
  1326. {
  1327.     EventRecord                     tossMe;
  1328.     if (Opts.GiveTime) {
  1329.     (void) WaitNextEvent(keyDownMask, &tossMe, 0, NULL);
  1330.     if (tossMe.what == keyDown)
  1331.         if (((tossMe.message & keyCodeMask) >> 8) == 0x2f)
  1332.         if (tossMe.modifiers & 0x0100)
  1333.             return 1;
  1334.     }
  1335.     return 0;
  1336. }
  1337.  
  1338. OSErr
  1339. FindOMFFile(char *name, short volrefnum, long dirID, FSSpec * f)
  1340. {
  1341.     FInfo                           junk;
  1342.     OSErr                           bad;
  1343.     Str255                          pname;
  1344.  
  1345.     strcpy(f->name, name);
  1346.     strcpy(pname, name);
  1347.     c2pstr(pname);
  1348.  
  1349.     /* Search path : current app dir, lib dir, etc... */
  1350.  
  1351.     bad = HGetFInfo(f->vRefNum = volrefnum, f->parID = dirID, pname, &junk);
  1352.     if (!bad)
  1353.     return bad;
  1354.  
  1355.     bad = HGetFInfo(f->vRefNum = Opts.StdAppVol, f->parID = Opts.StdAppDir, pname, &junk);
  1356.     if (!bad)
  1357.     return bad;
  1358.  
  1359.     bad = HGetFInfo(f->vRefNum = Opts.StdBuildVol, f->parID = Opts.StdBuildDir, pname, &junk);
  1360.     if (!bad)
  1361.     return bad;
  1362.  
  1363.     bad = HGetFInfo(f->vRefNum = Opts.StdLibVol, f->parID = Opts.StdLibDir, pname, &junk);
  1364.     if (!bad)
  1365.     return bad;
  1366.  
  1367.     return bad;
  1368. }
  1369.  
  1370. OSErr
  1371. FindCFile(char *name, short volrefnum, long dirID, FSSpec * f)
  1372. {
  1373.     FInfo                           junk;
  1374.     OSErr                           bad;
  1375.     Str255                          pname;
  1376.  
  1377.     strcpy(f->name, name);
  1378.     strcpy(pname, name);
  1379.     c2pstr(pname);
  1380.  
  1381.     /* Search path : current app dir, lib dir, etc... */
  1382.  
  1383.     bad = HGetFInfo(f->vRefNum = volrefnum, f->parID = dirID, pname, &junk);
  1384.     if (!bad)
  1385.     return bad;
  1386.  
  1387.     bad = HGetFInfo(f->vRefNum = Opts.StdAppVol, f->parID = Opts.StdAppDir, pname, &junk);
  1388.     if (!bad)
  1389.     return bad;
  1390.  
  1391.     bad = HGetFInfo(f->vRefNum = Opts.StdBuildVol, f->parID = Opts.StdBuildDir, pname, &junk);
  1392.     if (!bad)
  1393.     return bad;
  1394.  
  1395.     bad = HGetFInfo(f->vRefNum = Opts.StdLibVol, f->parID = Opts.StdLibDir, pname, &junk);
  1396.     if (!bad)
  1397.     return bad;
  1398.  
  1399.     return bad;
  1400. }
  1401. #endif
  1402.